package com.qianxx.viewlibrary.recyclerview.ainm;

import android.content.Context;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;

public class AnimRFGridLayoutManager extends GridLayoutManager {

	private OverScrollListener mListener;

	public AnimRFGridLayoutManager(Context context, AttributeSet attrs,
								   int defStyleAttr, int defStyleRes) {
		super(context, defStyleAttr);
	}

	public AnimRFGridLayoutManager(Context context, int spanCount) {
		super(context, spanCount);
	}

	public AnimRFGridLayoutManager(Context context, int spanCount,
								   int orientation, boolean reverseLayout) {
		super(context, spanCount, orientation, reverseLayout);
	}

	@Override
	public int scrollVerticallyBy(int dy, RecyclerView.Recycler recycler,
								  RecyclerView.State state) {
		int scrollRange = super.scrollVerticallyBy(dy, recycler, state);

		mListener.overScrollBy(dy - scrollRange);

		return scrollRange;
	}

	/**
	 * 设置滑动过度监听
	 *
	 * @param listener
	 */
	public void setOverScrollListener(OverScrollListener listener) {
		mListener = listener;
	}

}
